#include "server_car.h"
#include <ltobjectcreate.h>
#include "ServerShellCommon.h"
#include "iltrenderstyles.h"
#include "iltmodel.h"
#include "serverinterfaces.h"

BEGIN_CLASS(car)
END_CLASS_DEFAULT_FLAGS(car, BaseClass, LTNULL, LTNULL, CF_HIDDEN)

#include "server_physics.h"
car::car() : m_speed(0.0f,0.0f,0.0f) ,
    m_physicsBody(0) {
		m_point=0;
}

car::~car() {
}

uint32 car::OnPrecreate(ObjectCreateStruct* pStruct, float fData) {
    base_type::OnPrecreate(pStruct, fData) ;
    pStruct->m_ObjectType = OT_MODEL ;
    if(fData == PRECREATE_WORLDFILE) {
        read_props(pStruct) ;
    }
	pStruct->m_Flags = FLAG_FORCECLIENTUPDATE | FLAG_YROTATION | FLAG_VISIBLE | FLAG_MODELKEYS/*| FLAG_TOUCH_NOTIFY*/;
	pStruct->m_Flags2 = FLAG2_USEMODELOBBS;
	pStruct->m_Pos= LTVector(0.0f, 0.0f, 0.0f);
	pStruct->m_Scale=LTVector(0.1f, 0.1f, 0.1f);
	pStruct->m_Rotation=LTRotation();
    return 1 ;
}

LTVector car::position() const {
    LTVector pos ;
    g_pLTServer->GetObjectPos(GetHOBJECT(), &pos) ;
    return pos ;
}

LTRotation car::rotation() const {
    LTRotation rot ;
    g_pLTServer->GetObjectRotation(GetHOBJECT(), &rot) ;
    return rot ;
}

bool car::init_from_property(const char* propertyName) {
    if(!propertyName) return false ;
    
    return false ;
}

void car::set_position(const LTVector& pos) {
    g_pLTServer->SetObjectPos(GetHOBJECT(), &pos) ;
}

void car::set_rotation(const LTRotation& rot) {
    g_pLTServer->SetObjectRotation(GetHOBJECT(), &rot) ;
}

//car::car() : m_speed(0,0,0) {
//}

// FIXME
bool car::set_absolute_speed(const LTVector& speed) {
    m_speed = speed ;
    return true ;
}

void car::read_props(ObjectCreateStruct* pstruct) {
    g_pLTServer->GetPropString("Name", pstruct->m_Filename, MAX_CS_FILENAME_LEN) ;
}

void car::init_render_property()
{



}


